


gl dat "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Data"
gl res "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\Results"
gl temp "\\micro.intra\Projekt\P0624$\P0624_Gem\Politisk Geografi\temp"

cap log close
log using "$res\log\analysis.log", replace

cd "$temp"

gl e eps // eps pdf
use "$dat\main.dta", clear

*margin= (left right bottom top)

************************
**** Figure 1, A4, A5 **
************************

la var diff_vald_left_bef  "Left bloc politician"
la var diff_vald_right_bef "Center-right bloc politician"
la var diff_vald_left_vs  "Left bloc politician"
la var diff_vald_right_vs "Center-right bloc politician"
la var diff_vald_bef  "All politicians" 

foreach sample in all ab_med bel_med  {

	foreach pol in vald_bef vald_first_bef vald_left_bef  vald_right_bef vald_left_vs  vald_right_vs  {
preserve
local s=0
matrix C =J(7,6,.)

foreach var  in  diff_highq_bef   diff_highed_bef  diff_em_bef diff_own_bef  {
local s=`s'+1
reg `var' diff_`pol' if `sample'==1 [aw= w_dist_count], cluster(llkk)
sum `var'  if diff_`pol' !=. & `sample'==1 [aw= w_dist_count]
local sdy=r(sd) 
sum diff_`pol'   if `var'!=. & `sample'==1 [aw= w_dist_count]
local sdx=r(sd) 

	matrix C[`s',1]=(_b[ diff_`pol'])*`sdx'/`sdy'
	matrix C[`s',2]=(_b[ diff_`pol']+1.96*_se[ diff_`pol'])*`sdx'/`sdy'
	matrix C[`s',3]=(_b[ diff_`pol']-1.96*_se[ diff_`pol'])*`sdx'/`sdy'

}


svmat C
sum C*
 ren C1 est
	ren C2 ci_low
	ren C3 ci_high
gen pos =5-_n

drop if _n>4
tab pos

loc t	 "`:var label diff_`pol'', size(large)" 

if "`sample'"=="all" & "`pol'"=="vald_first_bef" loc t  "Elected for the first time"
if "`sample'"=="bel_med" & "`pol'"=="vald_bef" loc t "Municipalities below median size"
if "`sample'"=="ab_med" & "`pol'"=="vald_bef" loc t "Municipalities above median size"

loc set ysize(15) xsize(20) graphregion(margin(l=0 r=0))
loc y 4 "Top income quartile" 3 "Tertiary educated"  2 "Born in the West" 1 "Home owner" 

if ("`sample'"=="bel_med" & "`pol'"=="vald_bef") |  "`pol'"=="vald_left_bef" | "`pol'"=="vald_right_vs" {	
loc y 4 " " 3 " " 2 " " 1 " "
loc set ysize(15) xsize(20) graphregion(margin(l=25 r=10))
}
if ("`sample'"=="ab_med" & "`pol'"=="vald_bef") | "`pol'"=="vald_right_bef" {
loc y 4 " " 3 " " 2 " " 1 " "
loc set ysize(15) xsize(20) graphregion(margin(l=15 r =20))
}


twoway (scatter pos est , msize(medlarge)  msymbol(circle)   mcolor(black)) ///
(rbar ci_low ci_high pos , lwidth(vvthin)  fcolor(gs1) lcolor(gs1) lpattern(solid) horizontal barwidth(.015)) ///
	,xline(0, lcolor(gs1) lpattern(dash)) 	xlabel(, grid) ytitle(, size(zero))  ///
  scale(1) `set' scheme(s1mono) yscale(range(0.5 4.5))    leg(off) title(`t') ///
	ylabel(	`y' , labsize(medlarge) angle(horizontal)) 
graph save 	aff_`pol'_`sample', replace

	restore
	
	}
	}
	
loc spec col(3) iscale(1.5) scheme(s1mono)	 	b1("Estimated relationship with residential concentation of politicians (beta coefficients)", size(huge)) xcommon

	* figure 1		
	graph combine aff_vald_bef_all.gph aff_vald_left_bef_all.gph aff_vald_right_bef_all.gph, `spec' ysize(4) xsize(20)
graph export "$res\fig1.$e",  replace	
	
	*figure A4
graph combine  aff_vald_left_vs_all.gph aff_vald_right_vs_all.gph, `spec' ///
		 ysize(6) xsize(20)	
graph export "$res\figA4.$e",  replace	

	*figure A5
		graph combine  aff_vald_first_bef_all.gph aff_vald_bef_bel_med.gph aff_vald_bef_ab_med.gph, `spec' ysize(4) xsize(20) 
graph export "$res\figA5.$e",  replace



************************
***   Figur 2, A7    ***
************************

	foreach sample in all ab_med bel_med  {
	foreach ref in bef altbef  {
preserve
local s=0
matrix C =J(8,6,.)

	foreach p in  m c k f  g s v{
local s=`s'+1
reg  diff_votes_`p'_`ref'  diff_vald_`p'_bef if `sample'==1 [aw= w_dist_count], cluster(llkk)
sum  diff_votes_`p'_`ref'  if diff_vald_`p'_bef!=. & `sample'==1 [aw= w_dist_count]
local sdy=r(sd) 
sum diff_vald_`p'_bef  if diff_votes_`p'_`ref'!=. & `sample'==1 [aw= w_dist_count]
local sdx=r(sd) 
	matrix C[`s',1]=(_b[ diff_vald_`p'_bef ])*`sdx'/`sdy'
	matrix C[`s',2]=(_b[diff_vald_`p'_bef ]+1.96*_se[diff_vald_`p'_bef ])*`sdx'/`sdy'
	matrix C[`s',3]=(_b[diff_vald_`p'_bef ]-1.96*_se[ diff_vald_`p'_bef ])*`sdx'/`sdy'

	}

svmat C
sum C*
 ren C1 est
	ren C2 ci_low
	ren C3 ci_high

gen pos =_n

drop if _n>7
tab pos


loc y  1 "Conservative Party"  2 "Center Party" 3 "Christian Democrats" 4 "Liberal Party"  5 "Green Party"  ///
	 6 "Social Democrats" 7 "Left Party" 
if "`sample'"=="all" & "`ref'"=="bef" loc set ysize(15) xsize(20) graphregion(margin(l=0 r=7)) 
else loc set ysize(15) xsize(20) graphregion(margin(l=0 r=0)) 
loc xset xscale(range(0 0.7))	xlabel(0(0.1)0.7, grid)
loc t ""
if "`ref'"=="altbef" loc t "Alternative reference group"
if "`sample'"== "bel_med"	 {
loc t	"Municipalities below median size"
loc y 1 " " 2 " " 3 " " 4 " " 5 " " 6 " " 7 " "  
loc set ysize(15) xsize(20) graphregion(margin(l=25 r=10))	
}
if "`sample'"== "ab_med"	{
loc t	"Municipalities above median size"
loc y 1 " " 2 " " 3 " " 4 " " 5 " " 6 " " 7 " " 
loc set ysize(15) xsize(20) graphregion(margin(l=15 r=20))	
}
if "`sample'"=="all" & "`ref'"=="bef" loc x xtitle("Estimated relationship with residential concentation" "of each party's voters and politicians (beta coefficients)", size(medlarge))
else loc x " "
twoway (scatter pos est , msize(medlarge)  msymbol(circle)   mcolor(black)) ///
(rbar ci_low ci_high pos , lwidth(vvthin)  fcolor(gs1) lcolor(gs1) lpattern(solid) horizontal barwidth(.015)) ///
	,xline(0, lcolor(gs1) lpattern(dash))  ytitle(, size(zero))  ///
  scale(1) `set' `xset' scheme(s1mono) yscale(range(0.5 7.5))   legend(off) ///
	ylabel(	`y', labsize(medium) angle(horizontal)) title(`t') `x'
graph save 	polvotes_`ref'_`sample', replace

	restore
	
	}
	}


	
*	Figure 2
graph	use "polvotes_bef_all.gph" 
graph export "$res\fig2.$e",  replace
	

loc spec col(3) iscale(1.5) scheme(s1mono)	 	b1("Estimated relationship with residential concentation of each party's voters and politicians (beta coefficients)", size(huge))
* Figure A7		
	graph combine polvotes_altbef_all.gph polvotes_bef_bel_med.gph polvotes_bef_ab_med.gph, `spec' ysize(4) xsize(20) 
graph export "$res\figA7.$e", replace

	

**************************************	
***  Figures 3 and Figures A9.2   ***
**************************************
*define control variables 

gl pop_cont diff_highq_bef diff_highed_bef diff_own_bef diff_em_bef  diff_retired_bef diff_child_7_15_bef
gl turnout_cont diff_voters_bef
gl ecgeo_cont diff_b_area_multi diff_b_area_single  pop_dens_mdiff floorarea_pc_mdiff 


loc treat   diff_maj_min 
foreach var  in  area_multi  area_single    {
	foreach sample in all close  cl_bl   ab_med bel_med ab_med_c bel_med_c ab_med_cl_bl bel_med_cl_bl  {
 display "`var'" "`sample'"
	preserve
	local s=0
	matrix C =J(1,3,.)
	local s=`s'+1
	reg diff_`var'_bef `treat'   [pw=w_dist_count ] if `sample' ==1 ,cluster(llkk)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=6 if est_`s'!=.
	
	*****
	matrix C =J(1,3,.)
	local s=`s'+1
	reg diff_`var'_bef `treat'  $pop_cont [pw=w_dist_count ] if `sample' ==1 ,  cluster(llkk)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=5 if est_`s'!=.
	
	
		*****
	matrix C =J(1,3,.)
	local s=`s'+1
	reg diff_`var'_bef `treat'   $turnout_cont [pw=w_dist_count ] if `sample' ==1 ,  cluster(llkk)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=4 if est_`s'!=.
	
	****
	local s=`s'+1
    reg diff_`var'_bef `treat'    $ecgeo_cont  [pw=w_dist_count ] if `sample' ==1 ,  cluster(llkk)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])


	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=3 if est_`s'!=.
	
	****
	local s=`s'+1
    reg diff_`var'_bef `treat'    diff_`var'_lag_bef [pw=w_dist_count ] if `sample' ==1 ,  cluster(llkk)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=2 if est_`s'!=.
	****
	
	local s=`s'+1
	reg diff_`var'_bef `treat'    diff_`var'_lag_bef  $ecgeo_cont $turnout_cont	$pop_cont ///
  [pw=w_dist_count ] if `sample' ==1 ,   cluster(llkk)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=1 if est_`s'!=.
	****

loc t " "	
if ("`sample'"=="all" & "`var'"=="area_multi" ) | "`sample'"=="ab_med" loc t "All elections"
if ("`sample'"== "close" & "`var'"=="area_multi" ) | "`sample'"=="ab_med_c"  loc t "Close elections"
if ("`sample'"=="cl_bl" & "`var'"=="area_multi" )| "`sample'"=="ab_med_cl_bl" loc t "Close elections, no dominant bloc"

loc marg graphregion(margin(2 2 0 0))
if "`var'"=="area_multi" & "`sample'"!="bel_med" & "`sample'"!="bel_med_c" & "`sample'"!="bel_med_cl_bl"  loc marg graphregion(margin(2 2 3 0))
if "`var'"=="area_single" &  ("`sample'"=="ab_med" | "`sample'"=="ab_med_c" | "`sample'"=="ab_med_cl_bl" ) loc marg graphregion(margin(2 2 3 0))



loc xset1 -0.4(0.1)0.1
loc xset2 -0.4 0.1

if ("`sample'"!="all" & "`sample'"!= "close" & "`sample'"!="cl_bl" & "`var'"=="area_multi") {
loc xset1 -0.6(0.2)0.15
loc xset2 -0.6 0.15
}

if ("`sample'"!="all" & "`sample'"!= "close" & "`sample'"!="cl_bl" & "`var'"=="area_single") {
loc xset1 -0.4(0.2)0.2
loc xset2 -0.4 0.2
}

loc x xlabel(`xset1' , angle(horizontal) grid labsize(medium))  xscale(range(`xset2')) 
if  "`var'"=="area_multi" & "`sample'"!="bel_med" & "`sample'"!="bel_med_c" & "`sample'"!="bel_med_cl_bl"  loc x xlabel(`xset1' , grid nolabels) xscale(range(`xset2')) 
if "`var'"=="area_single" &  ("`sample'"=="ab_med" | "`sample'"=="ab_med_c" | "`sample'"=="ab_med_cl_bl" ) loc x xlabel(`xset1' , grid nolabels) xscale(range(`xset2')) 


loc l1	 legend(on order(1 "No controls" 3  "Population composition" 5 "Turnout" 7 "Economic Geography" 9 "Lagged outcome control" 11 "All controls") rows(1) 
if "`sample'"=="ab_med" loc l `l1' size(tiny))
if  "`sample'"!="ab_med" loc l `l1' size(small))

* top part-yscale
twoway (scatter  pos_1 est_1  , msize(medlarge)  msymbol(circle)   mcolor(gs1)) ///
	(rbar ci_low_1 ci_high_1 pos_1 , lwidth(vvthin)  fcolor(gs1) lcolor(gs1) lpattern(solid) horizontal barwidth(.015)) ///
	(scatter  pos_2 est_2  , msize(medlarge)  msymbol(circle)  mcolor(gs3)) ///
	(rbar ci_low_2 ci_high_2 pos_2 , lwidth(vvthin)  fcolor(gs3) lcolor(gs3) lpattern(solid) horizontal barwidth(.015)) ///
	(scatter  pos_3 est_3  , msize(medlarge)  msymbol(circle)  mcolor(gs5)) ///
	(rbar ci_low_3 ci_high_3 pos_3 , lwidth(vvthin)  fcolor(gs5) lcolor(gs5) lpattern(solid) horizontal barwidth(.015)) ///
	(scatter  pos_4 est_4  , msize(medlarge)  msymbol(circle)  mcolor(gs7)) ///
	(rbar ci_low_4 ci_high_4 pos_4 , lwidth(vvthin)  fcolor(gs7) lcolor(gs7) lpattern(solid) horizontal barwidth(.015)) ///
		(scatter  pos_5 est_5  , msize(medlarge)  msymbol(circle)  mcolor(gs9)) ///
	(rbar ci_low_5 ci_high_5 pos_5 , lwidth(vvthin)  fcolor(gs7) lcolor(gs9) lpattern(solid) horizontal barwidth(.015)) ///
	(scatter  pos_6 est_6  , msize(medlarge)  msymbol(circle)  mcolor(gs11)) ///
	(rbar ci_low_6 ci_high_6 pos_6 , lwidth(vvthin)  fcolor(gs7) lcolor(gs11) lpattern(solid) horizontal barwidth(.015)) ///
	,xline(0, lcolor(gs7) lpattern(dash))  yscale(range(0.5 6.5)) xtitle("") ///
	 ytitle(, size(zero)) ylabel(none)  scale(.7) ysize(10) xsize(20) scheme(s1mono)  ///
	   title("`t'", size(large)) ///
`marg' `l' `x'

	 graph save reg_`treat'_`sample'_`var', replace

restore
	
		}
		}

*fig 3
loc set 	ysize(10) xsize(20)  iscale(1.2) scheme(s1mono)	xcommon 
grc1leg  reg_diff_maj_min_all_area_multi.gph  reg_diff_maj_min_close_area_multi.gph reg_diff_maj_min_cl_bl_area_multi.gph, t1("Approved permits for multi-family homes (sqm)", size(medlarge) ) `set' col(3)	
graph display,  ysize(10) xsize(25)	
	 graph save temp1, replace
grc1leg  reg_diff_maj_min_all_area_single.gph   reg_diff_maj_min_close_area_single.gph reg_diff_maj_min_cl_bl_area_single.gph , t1("Approved permits for single-family homes (sqm)", size(medlarge) ) `set' col(3) 
graph display,  ysize(10) xsize(25)	
	 graph save temp2, replace

grc1leg temp1.gph temp2.gph, rows(2) iscale(0.9) scheme(s1mono) leg(temp2.gph) b1("Estimated effect of residential concentration of majority vs. opposition politicians", size(medium)) ring(2)
graph display,  ysize(15) xsize(27)		 
graph export "$res\fig3.$e", replace



	  
*fig A9.2
loc set 	ysize(12) xsize(20)  iscale(1.1) scheme(s1mono)	xcommon 

grc1leg  reg_diff_maj_min_ab_med_area_multi.gph reg_diff_maj_min_ab_med_c_area_multi.gph  reg_diff_maj_min_ab_med_cl_bl_area_multi.gph ,  `set' col(3) ///
	t1("Above median size", size(medium))
graph save temp1, replace

grc1leg reg_diff_maj_min_bel_med_area_multi.gph  reg_diff_maj_min_bel_med_c_area_multi.gph  reg_diff_maj_min_bel_med_cl_bl_area_multi.gph , `set' ///
col(3) t1("Below median size", size(medium))
graph save temp2, replace

grc1leg temp1.gph temp2.gph, rows(2) t1("Approved permits for multi-family homes (sqm)", size(medlarge) ) 
graph display,  ysize(10) xsize(20)
graph save temp3, replace


grc1leg reg_diff_maj_min_ab_med_area_single.gph reg_diff_maj_min_ab_med_c_area_single.gph reg_diff_maj_min_ab_med_cl_bl_area_single.gph  , `set' ///
 col(3)	t1("Above median size", size(medium))
graph save temp4, replace

grc1leg  reg_diff_maj_min_bel_med_area_single.gph  reg_diff_maj_min_bel_med_c_area_single.gph reg_diff_maj_min_bel_med_cl_bl_area_single.gph , `set' ///
col(3) t1("Below median size", size(medium))  	
graph save temp5, replace			

grc1leg temp4.gph temp5.gph, rows(2) t1("Approved permits for single-family homes (sqm)", size(medlarge) )  
graph display,  ysize(10) xsize(20)	
graph save temp6, replace
	 

grc1leg temp3.gph temp6.gph, rows(2) iscale(0.7) scheme(s1mono)  b1("Estimated effect of residential concentration of majority vs. opposition politicians", size(vsmall)) ring(2) leg(temp3.gph)
graph display,  ysize(90) xsize(77)		  
graph export "$res\figA92.$e", replace	  





** Testing equality of point estimates in close election samples with different sets of control variables (c.f. Figure 3 in the paper and corresponding text)

reg diff_area_multi_bef diff_maj_min [iw=w_dist_count] if all==1 
est store m1
reg diff_area_multi_bef diff_maj_min $ecgeo_cont $turnout_cont	$pop_cont  diff_area_multi_lag_bef [iw=w_dist_count] if all==1
est store m2
suest m1 m2, cluster(llkk_year)
test [m1_mean = m2_mean], common

reg diff_area_multi_bef diff_maj_min [iw=w_dist_count] if close==1 
est store m3
reg diff_area_multi_bef diff_maj_min $ecgeo_cont $turnout_cont	$pop_cont  diff_area_multi_lag_bef [iw=w_dist_count] if close==1
est store m4
suest m3 m4, cluster(llkk_year)
test [m3_mean = m4_mean], common

reg diff_area_multi_bef diff_maj_min [iw=w_dist_count] if cl_bl==1 
est store m5
reg diff_area_multi_bef diff_maj_min $ecgeo_cont $turnout_cont	$pop_cont diff_area_multi_lag_bef [iw=w_dist_count] if cl_bl==1
est store m6
suest m5 m6, cluster(llkk_year)
test [m5_mean = m6_mean], common
	 
	 	
	 
*************************	  
***    Figure 4
************************
    
foreach treat in  diff_maj_min{
foreach var  in   area_multi area_single  {
	foreach sample in  all close cl_bl  {
 preserve

	local s=0
	matrix C =J(1,3,.)
	local s=`s'+1
	reg diff_`var'_bef `treat'  [pw=w_dist_count ] if `sample' ==1 ,cluster(llkk)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=4 if est_`s'!=.
	
	*****
	matrix C =J(1,3,.)
	local s=`s'+1
	reg diff_`var'_bef `treat' diffvs_maj_min [pw=w_dist_count ] if `sample' ==1 ,  cluster(llkk) 
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=3 if est_`s'!=.
	
	
		*****
	matrix C =J(1,3,.)
	local s=`s'+1
	areg diff_`var'_bef `treat'  i.majvs_4q  [pw=w_dist_count ] if `sample' ==1 ,  cluster(llkk) abs(llkk_year)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])

	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=2 if est_`s'!=.
	
	****
	local s=`s'+1
 	areg diff_`var'_bef `treat'   i.majvs_10q  [pw=w_dist_count ] if `sample' ==1 ,  cluster(llkk) abs(llkk_year)
	matrix C[1,1]=_b[ `treat']
	matrix C[1,2]=(_b[ `treat']+1.96*_se[ `treat'])
	matrix C[1,3]=(_b[ `treat']-1.96*_se[ `treat'])
	svmat C
	ren C1 est_`s'
	ren C2 ci_low_`s'
	ren C3 ci_high_`s'
	gen pos_`s'=1 if est_`s'!=.
	

if "`sample'"=="all"  loc t "All elections"
if "`sample'"== "close"  loc t "Close elections"
if "`sample'"=="cl_bl" loc t "Close elections, no dominant bloc"

* top part-yscale
twoway (scatter  pos_1 est_1  , msize(vlarge)  msymbol(circle)   mcolor(gs1)) ///
	(rbar ci_low_1 ci_high_1 pos_1 , lwidth(vvthin)  fcolor(gs1) lcolor(gs1) lpattern(solid) horizontal barwidth(.015)) ///
	(scatter  pos_2 est_2  , msize(vlarge)  msymbol(circle)  mcolor(gs6)) ///
	(rbar ci_low_2 ci_high_2 pos_2 , lwidth(vvthin)  fcolor(gs6) lcolor(gs6) lpattern(solid) horizontal barwidth(.015)) ///
	(scatter  pos_3 est_3  , msize(vlarge)  msymbol(circle)  mcolor(gs8)) ///
	(rbar ci_low_3 ci_high_3 pos_3 , lwidth(vvthin)  fcolor(gs8) lcolor(gs8) lpattern(solid) horizontal barwidth(.015)) ///
	(scatter  pos_4 est_4  , msize(vlarge)  msymbol(circle)  mcolor(gs10)) ///
	(rbar ci_low_4 ci_high_4 pos_4 , lwidth(vvthin)  fcolor(gs10) lcolor(gs10) lpattern(solid) horizontal barwidth(.015)) ///
	,xline(0, lcolor(gs7) lpattern(dash)) yscale(range(0.5 4.5)) xtitle("") ///
	 ytitle(, size(zero)) ylabel(none)  scale(.7) ysize(10) xsize(20) scheme(s1mono) title("`t'", size(vhuge)) ///
	 legend(on order(1 "Main specification" 3  "Linear control for own voters" ///
	 5 "Quartile control for own voters" 7  "Decile control for own voters") rows(1) size(huge))  xlabel(, angle(horizontal) grid labsize(vlarge)) graphregion(margin(5 5 0 0))
graph save vc_`sample'_`var', replace
restore
	
		}
		}	
		}			  

grc1leg vc_all_area_multi.gph vc_close_area_multi.gph vc_cl_bl_area_multi.gph	, ///
	   ysize(5) xsize(20) col(3) iscale(1.25) scheme(s1mono) xcommon ///
	   b1("Estimated effect of residential concentration of majority vs. opposition politicians", size(vhuge)) ring(2) 
	   graph display, xsize(20) ysize(5) 
graph export "$res\fig4.$e", replace

  

log close 				 
